﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NibbleOil.Web.Business.Helper
{
    public static class User
    {
        public static Business.Model.USUARIO ValidateUser(string email, string password)
        {
            Model.USUARIO bResult = null;
            IQueryable<Model.USUARIO> oResult = DataContext.Instance.Model.USUARIO.Where(u => u.Email.Equals(email) && u.Clave.Equals(password));

            foreach (Model.USUARIO user in oResult)
            {
                bResult = user;
            }


            return bResult;
        }

        public static Model.USUARIO GetData(string email)
        {
            Model.USUARIO oResult = null;
            IQueryable<Model.USUARIO> oUser = DataContext.Instance.Model.USUARIO.Where(u => u.Email.Equals(email));

            foreach (Model.USUARIO user in oUser)
            {
                oResult = user;
            }

            return oResult;
        }

        public static bool Update(Model.USUARIO pUser)
        {
            bool bResult = false;
            try
            {                
                DataContext.Instance.Model.SaveChanges();
                bResult = true;
            }
            catch
            {
            }

            return bResult;
        }
    }           
}
